<template>
	<!--增加企业抬头-->
	<view class="content">
		<view class="details-from">
			<form>
				<view class="uni-details-list">
					<view class="title">默认抬头:</view>
					<u-switch size="20" v-model="value" @change="setDefault"></u-switch>
				</view>
				<view class="uni-details-list">
					<view class="title">名称:</view>
					<view class="uni-input-01"><input name="input" placeholder="请输入名称" v-model="riseListPro.name" /></view>
				</view>
				<view class="uni-details-list">
					<view class="title">税号:</view>
					<view class="uni-input-01"><input name="input" placeholder="请输入税号" v-model="riseListPro.taxNo" /></view>
				</view>
				<view class="uni-details-list">
					<view class="title">企业地址:</view>
					<view class="uni-input-02"><input name="input" placeholder="非必填" v-model="riseListPro.address" /></view>
				</view>
				<view class="uni-details-list">
					<view class="title">企业电话:</view>
					<view class="uni-input-02"><input name="input" placeholder="非必填" v-model="riseListPro.phone" /></view>
				</view>
				<view class="uni-details-list">
					<view class="title">开户银行:</view>
					<view class="uni-input-02"><input name="input" placeholder="请输入开户银行" v-model="riseListPro.bankAccNo" /></view>
				</view>
				<view class="uni-details-list">
					<view class="title">开户账号:</view>
					<view class="uni-input-02"><input name="input" placeholder="请输入开户账号" v-model="riseListPro.bankNm" /></view>
				</view>
				<view class="uni-details-list">
					<view class="title">邮箱:</view>
					<view class="uni-input-01"><input name="input" placeholder="请输入邮箱" v-model="riseListPro.email" /></view>
				</view>

				<view class="ad-button">
					<button form-type="submit" @tap="keyword" class="button">提交</button>
					<button type="default" form-type="reset" class="button">清空</button>
				</view>
			</form>
		</view>
	</view>
</template>
<script>
export default {
	data() {
		return {
			riseListPro: {
				name: '',
				taxNo: '',
				address: '',
				phone: '',
				bankNm: '',
				bankAccNo: '',
				email: '',
				defaultFlag: ''
			},
			flag: '1',
			value:true
		};
	},
	onLoad() {
		// uni.getStorageInfoSync(ids);
		// console.log('------');
		// console.log('ids' + ids);
		// console.log('------');
	},
	methods: {
		keyword(e) {
			console.log(e);
			var me = this;
			console.log('-------111111111-----');
			console.log(me.riseListPro);
			var userinfo = uni.getStorageSync('user');
			//打印数值
			console.log('user' + JSON.stringify(userinfo));
			if(!this.riseListPro.name){
				uni.showToast({
					title:'名称不能为空',
					icon:'none'
				})
			}else if(!this.riseListPro.taxNo){
				uni.showToast({
					title:'税号不能为空',
					icon:'none'
				})
			
			}else{
				uni.request({
					url: me.$ServerUrl + '/invoice/api/header/saveInvoiceHeader', //增加发票
					header: {
						'content-type': 'application/json' // 默认值
					},
					data: {
						customer: {
							id: userinfo.id
						},
						name: this.riseListPro.name,
						taxNo: this.riseListPro.taxNo,
						address: this.riseListPro.address,
						phone: this.riseListPro.phone,
						bankNm: this.riseListPro.bankNm,
						bankAccNo: this.riseListPro.bankAccNo,
						email: this.riseListPro.email,
						defaultFlag: this.flag
					},
					method: 'POST',
					success(res) {
						console.log(res);
						console.log('-------增加成功-----');
						// 你在成功之后跳转页面的方式跳回来也可以 你在成功之后跳转页面的方式跳回来也可以
						uni.redirectTo({
							url: '/pages/user/mine/mine-wdtt/mine-wdtt-qy/ttlb',
							success() {
								let page = getCurrentPages().pop(); //跳转页面成功之后
								if (!page) return;
								page.onLoad(); //如果页面存在，则重新刷新页面
							}
						});
					}
				});
			}
			
		},
		setDefault() {
			var me = this;
			if (me.flag == 1) {
				me.flag = 0;
			} else {
				me.flag = 1;
			}
			console.log(me.flag);
		}
	}
};
</script>

<style>

page {
	width: 100%;
	height: 100%;
	background-color: #e1e5eb;
}

.content {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
}

.details-from {
	width: 100%;
	height: 100%;
	padding: 10px;
}

.uni-details-list {
	border: 1px solid #ffffff;
	display: flex;
	background-color: #ffffff;
	align-items: center;
	padding: 10px;
	margin-bottom: 5px;
	border-radius: 10px;
	margin-left: 10px;
	margin-right: 10px;
}

.ad-text {
	margin-left: 10px;
}

.title {
	font-size: 14px;
	width: 65px;
}

.uni-input-01 {
	font-size: 14px;
	margin-left: 10px;
	width: 80%;
	overflow:auto;
}
.uni-input-01 input {
	width: 90%;
}
.uni-input-02 input {
	width: 90%;
}
.uni-input-02 {
	font-size: 14px;
	margin-left: 5px;
	width: 80%;
	overflow:auto;
}

.button-02 {
	margin: 10px;
	color: #ffffff;
	background-color: #ce0000;
}

.button {
	margin: 10px;
	color: #ffffff;
	background-color: #004fa3;
}

.swiths {
	margin-left: 10px;
	transform: scale(0.7);
}
</style>
